home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d21 / dvglue10.arc / TVINT15.C < prev    next >
C/C++ Source or Header  |  1988-08-13  |  6KB  |  121 lines

  1. /******************************************************************************/
  2. /*     TVINT15.C - C interface functions                                      */
  3. /*     IBM Personal Computer - TopView/DESQview C Interface Header File.      */
  4. /*     Written for Borland Turbo C v1.5.                                      */
  5. /*     (Microsoft MASM or A86 is required to recompile these functions.)      */
  6. /******************************************************************************/
  7.  
  8. #pragma inline
  9.  
  10. #include "tvapi.h"      /* types and function prototypes */
  11.  
  12. /*======================================================*/
  13. /* TVsendmsg   send a message to a TopView object       */
  14. /*   John Navas                                         */
  15. /*   Ralf Brown 4/22/88 made work if already on private */
  16. /*                      stack--don't switch             */
  17. /*   Ralf Brown 6/20/88 fix again by not using private  */
  18. /*                      stack at all                    */
  19. /*======================================================*/
  20.  
  21. void pascal TVsendmsg(WORD msg_num,WORD modifier,OBJECT object_hdl,PARMLIST far *msg_args)
  22.                                              /* object handle 0 = none */
  23. {
  24.    asm  mov     ax,sp           ; /* save stack pointer */
  25.    asm  mov     bh,msg_num      ; /* get the message number */
  26.    asm  mov     bl,modifier     ; /*  and the modifier */
  27.    asm  les     di,object_hdl   ; /* get the object handle */
  28.    asm  mov     dx,es           ; /* . */
  29.    asm  les     si,msg_args     ; /* get address of msg_args record parameter */
  30.    asm  mov     cx,es:[si]      ; /* number of arguments */
  31.    asm  jcxz    send40          ; /* none */
  32. send30:
  33.    asm  push    es:[si+4]       ; /* push argument h on stack */
  34.    asm  push    es:[si+2]       ; /* push argument l on stack */
  35.    asm  add     si,4            ; /* point to next */
  36.    asm  loop    send30          ; /* until done */
  37.    asm  sub     si,ax           ; /* restore argument pointer */
  38.    asm  add     si,sp
  39. send40:
  40.    asm  mov     cx,dx           ; /* test object pointer */
  41.    asm  or      cx,di
  42.    asm  jz      send50          ; /* none */
  43.    asm  push    dx              ; /* push the object pointer */
  44.    asm  push    di              ;
  45. send50:
  46.    asm  mov     cx,ax           ; /* save original stack pointer */
  47.    asm  mov     ah,12h          ; /* get the send message function code */
  48.    asm  int     15h             ; /* issue the interrupt request */
  49.    asm  sub     cx,sp           ; /* calculate the number of bytes returned */
  50.    asm  mov     ax,cx           ; /* save the number of bytes */
  51.    asm  shr     cx,1            ; /* shift right twice to divide by 4 giving the */
  52.    asm  shr     cx,1            ; /*  number of msg_args arguments returned */
  53.    asm  mov     es:[si],cx      ; /*  and put in # of args to be returned */
  54.    asm  jcxz    send70          ; /* if no arguments returned then continue */
  55.    asm  add     si,ax           ; /* advance pointer to last slot in result area */
  56. send60:
  57.    asm  pop     es:[si-2]       ; /* pop "l" part of argument into result list */
  58.    asm  pop     es:[si]         ; /* pop "h" part of argument into result list */
  59.    asm  sub     si,4            ; /* skip back 4 bytes to next argument */
  60.    asm  loop    send60          ; /* loop if there are more arguments to move */
  61. send70:
  62. }
  63.  
  64. /*======================================================*/
  65. /* TVsendmsg0   send a message without parameters to a  */
  66. /*              TopView object                          */
  67. /*   John Navas                                         */
  68. /*   Ralf Brown 4/22/88 made work if already on private */
  69. /*                      stack--don't switch             */
  70. /*   Ralf Brown 4/23/88 modified TVsendmsg for no parms */
  71. /*======================================================*/
  72.  
  73. void pascal TVsendmsg0(WORD msg_num,WORD modifier,OBJECT object_hdl)
  74.                                              /* object handle 0 = none */
  75. {
  76.    asm  mov     cx,sp           ; /* save stack pointer */
  77.    asm  mov     bh,msg_num      ; /* get the message number */
  78.    asm  mov     bl,modifier     ; /*  and the modifier */
  79.    asm  les     di,object_hdl   ; /* get the object handle */
  80.    asm  mov     ax,es           ; /* test object pointer */
  81.    asm  or      ax,di
  82.    asm  jz      send1           ; /* none */
  83.    asm  push    es              ; /* push the object pointer */
  84.    asm  push    di              ;
  85. send1:
  86.    asm  mov     ah,12h          ; /* get the send message function code */
  87.    asm  int     15h             ; /* issue the interrupt request */
  88.    asm  mov     sp,cx           ; /* restore stack pointer, removing ret values */
  89. }
  90.  
  91. /*======================================================*/
  92. /* TVsendmsg1   send a message without parameters to a  */
  93. /*              TopView object, return single result    */
  94. /*   John Navas                                         */
  95. /*   Ralf Brown 4/22/88 made work if already on private */
  96. /*                      stack--don't switch             */
  97. /*   Ralf Brown 4/23/88 modified TVsendmsg for no parms */
  98. /*   Ralf Brown 6/21/88 modified from TVsendmsg0        */
  99. /*======================================================*/
  100.  
  101. DWORD pascal TVsendmsg1(WORD msg_num,WORD modifier,OBJECT object_hdl)
  102.                                              /* object handle 0 = none */
  103. {
  104.    asm  mov     bh,msg_num      ; /* get the message number */
  105.    asm  mov     bl,modifier     ; /*  and the modifier */
  106.    asm  les     di,object_hdl   ; /* get the object handle */
  107.    asm  mov     ax,es           ; /* test object pointer */
  108.    asm  or      ax,di
  109.    asm  jz      send1           ; /* none */
  110.    asm  push    es              ; /* push the object pointer */
  111.    asm  push    di              ;
  112. send1:
  113.    asm  mov     ah,12h          ; /* get the send message function code */
  114.    asm  int     15h             ; /* issue the interrupt request */
  115.    asm  pop     ax              ; /* get result value */
  116.    asm  pop     dx
  117. /* TurboC will warn about not returning a value, but we really are in DX:AX */
  118. }
  119.  
  120. /* end TVINT15.C */
  121.